require("Location")

World = class("World", Location)

---

function World:initialize()

	self.observedLocations = {}
	
	Location.initialize(self, "World", "World")	
end

---

function World:onBeat()


	-- collect locations related to player current location
	
	self.observedLocations = {}
	gPlayer.body:getCollapsedProperty("CurrentContainer"):propagateObservation()
	
	
	-- observe Physical entities that are in observed locations
	
	gLogger:enterGroup("Observe Physical entities")
		
	for locationName, location in pairs(self.observedLocations) do
	
		gLogger:enterGroup(locationName)
		
		location:applyToCotainedEntities(self, "Physical", 
			function(self, entity)
			
				entity:observe(location)
			end
		)
		
		gLogger:leaveGroup()
	end
	
	gLogger:leaveGroup()
end
  